<template>
    <div>

        <el-form :inline="true" :model="searchDate" class="demo-form-inline">
            <el-form-item label="药房名称">
                <el-input v-model="searchDate.name" placeholder="药房名称"></el-input>
            </el-form-item>
            <el-form-item label="所属地区">
                <el-input v-model="searchDate.address" placeholder="所属地区"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="SelectMultipel">查询</el-button>
            </el-form-item>
            <el-form-item style="float:right">
                <el-button type="primary" @click="onAdd">新增</el-button>
            </el-form-item>
        </el-form>
        <div class="space20">
        </div>
        <el-table v-if="tableData3.length>0" :data="tableData3" border style="width: 100%"  @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55">
            </el-table-column>
            <el-table-column prop="PHARMACY_ID" label="ID" width="180">
            </el-table-column>
            <el-table-column prop="PHARMACY_NAME" label="名称" width="180">
            </el-table-column>
            <el-table-column prop="PHARMACY_ADDRESS" label="所属地区" width="150">
            </el-table-column>
            <el-table-column prop="PHARMACY_ADDRESSDETAIL" label="详细地址" width="180">
            </el-table-column>
            <el-table-column prop="PHARMACY_TEL" label="电话" width="200">
            </el-table-column>

          
        </el-table>
        <div class="block">
            <el-pagination @current-change="handleCurrentChange" :current-page="currentPage1" :page-size="10" layout="total, prev, pager, next" :total="pagecount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import api from "@/js/api";
export default {
  data() {
    return {
      pagecount: 0,
      name: "",
      currentPage1: 1,
      tableData3: [],
      searchDate: {
        name: "",
        address: ""
      },
      multipleSelection:[]
    };
  },
    props: {
        id: {
            type: {
                type: String,
                default: ""
            }
        },
        type: {
            type: String,
            default: "待沟通"
        }
    },
    methods: {       
       SelectMultipel() {     
      var data=this.searchDate;
      let that = this;
      var sdata = {
        name: data.name == "" ? null : data.name,
        address: data.address == "" ? null : data.address,
        pageIndex: this.currentPage1,
        pageSize: 10
      };
      api.PHARMACYSelectMultipel(that, sdata, function(msg) {
        that.tableData3 = msg.Result;
        that.pagecount = msg.ListCount;
      });
    },
    handleCurrentChange(val) {
      this.currentPage1 = val;
      this.SelectMultipel();
    },
    getDate() {
      let that = this;
      api.PHARMACYGetList(
        that,
        { pageIndex: this.currentPage1, pageSize: 10 },
        function(msg) {
          that.tableData3 = msg.Result;
          that.pagecount = msg.ListCount;
        }
      );
    },
    onAdd(){
          this.$emit("SelectPHARMACY",  this.multipleSelection);
    },
     handleSelectionChange(val) {
        this.multipleSelection = val;
      }
  },
  created() {
    this.getDate();
  }
};
</script>
